export const schema = {
    type: "page",
    title: "保险方案管理",
    toolbar: {
        type: 'button',
        actionType: 'link',
        link: '/safe_plan/create',
        label: '创建保险方案',
        level: 'info'
    },
    body: {
        type: "crud",
        api: "/api/safe_plan",
        columnsTogglable: false,
        columns: [
            {
                name: "id",
                label: "ID"
            },
            {
                label: "保险名称",
                name: "name"
            },
            {
                label: "保险公司",
                name: 'company'
            },
            {
                label: "保险金额",
                name: 'price'
            },
            {
                type: 'tpl',
                label:'详情链接',
                tpl: '<a href="${detail_link}">${detail_link}</a>'
            },
            {
                label: '状态',
                name: 'status',
                type: 'map',
                map: {
                    '*': '<span class="label label-default">未启动</span>',
                    '1': '<span class="label label-info">已启动</span>'
                }
            },
            {
                label: "操作",
                type: "operation",
                width: 180,
                buttons: [
                    {
                        type: "button",
                        size: "xs",
                        level: "info",
                        label: "编辑",
                        actionType: "link",
                        link: "/safe_plan/edit/${id}"
                    },

                    {
                        type: "button",
                        size: "xs",
                        level: "danger",
                        label: "下架",
                        actionType: 'ajax',
                        visibleOn: 'data.status == 1',
                        api: '/api/safe_plan/offline/${id}'
                    },
                    {
                        type: "button",
                        size: "xs",
                        level: "success",
                        label: "上架",
                        visibleOn: 'data.status == 0',
                        actionType: 'ajax',
                        api: '/api/safe_plan/online/${id}'
                    },
                    {
                        type: "button",
                        size: "xs",
                        level: "danger",
                        label: "删除",
                        confirmText: '确定要删除？',
                        actionType: 'ajax',
                        api: 'delete:/api/safe_plan/${id}'
                    },
                ]
            }
        ]
    }
};
